package pri.zey.custom.AFMananger;/**
 * Created by Administrator on 2016/4/14 0014.
 */

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * activity视图基类（使用者activity继承类）
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class ActivityView extends Activity implements InterfaceName{

    protected ActivityModle modle;
    protected Message Msg;
    protected InterfaceHandler IHandler;

    protected Handler MsgHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            switch (msg.what){
                case SMsgCode://指定对象执行Sen之后，执行传handler类此方法
                    Bundle bundle = msg.getData();
                    ActivityBase av = (ActivityBase) msg.obj;
                    Message age = new Message();
                    age.what = GMsgCode;
                    av.MsgHandler.sendMessage(age);
                    Log.i("TAGSS", "SMsgCode ： " + SMsgCode);
                    Log.i("TAGSS", "what : " + msg.what);
                    Log.i("TAGSS", "obj : " +  msg.obj);
                    Log.i("TAGSS", "arg1 : " +  msg.arg1);
                    Log.i("TAGSS", "arg2 : " +  msg.arg2);
                    IHandler.onRequest(av);
                    break;
                case GMsgCode://
                    Log.i("TAGSS", "GMsgCode ： " + GMsgCode);
                    Log.i("TAGSS", "what : " + msg.what);
                    Log.i("TAGSS", "obj : " +  msg.obj);
                    Log.i("TAGSS", "arg1 : " +  msg.arg1);
                    Log.i("TAGSS", "arg2 : " +  msg.arg2);
                    IHandler.onResponse(null);
                    break;
                case 110:
                    Log.i("TAGSS", "调用顶部对象send");
                    ActivityBase ab = (ActivityBase)msg.obj;
                    ab.MsgHandler.sendEmptyMessage(120);
                    Log.i("TAGSS", "obj : " + ab.getName());
                    break;
                case 120:
                    Log.i("TAGSS", "调用obj对象send");
                    break;
                default:
                    break;
            }
            return false;
        }
    });

    private String Name;
    private String PakeName;
    public final int SMsgCode = 0x1000;

    public final int GMsgCode = 0x2000;

    public ActivityView() {
        setName(this.getClass().getName());
    }

    @Override
    public String getName() {
        return this.Name;
    }

    @Override
    public void setName(String name) {
        this.Name = name;
    }

    @Override
    public String getPakeName() {
        return PakeName;
    }

    @Override
    public void setPakeName(String pakeName) {
        PakeName = pakeName;
    }

    public Message getMsg() {
        return Msg;
    }

    public void setMsg(Message msg) {
        Msg = msg;
    }

    public ActivityModle getModle() {
        return modle;
    }

    public void setModle(ActivityModle modle) {
        this.modle = modle;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setName(this.getClass().getName());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        CustomApplication.control.del(this);
    }
}
